<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('客户wip已确认数据列表')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label class="control-label is-required">日期：</label>
                                <input type="text" class="input-sm" id="timeFlag" name="timeFlag" th:value="2022-09-15" required/>
                            </li>
                            <li>
                                <label>客户名称：</label>
                                <select name="customerName" th:with="cus=${cwWipCustomerInfo}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${cus}" th:text="${dict.customerName}" th:value="${dict.customerName}"></option>
                                </select>
                            </li>
                            <li>
                                <label>产品名称：</label>
                                <input type="text" name="partName" />
                            </li>
                            <li>
                                批次类型：
                                <select name="lotType" th:with="type=${@dict.getType('lot_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-primary multiple disabled" onclick="cancelconfirm()" shiro:hasPermission="wip:confirm:cancelconfirm">
                    <i class="fa fa-remove"></i> 取消确认
                </a>
                <a class="btn btn-info" onclick="$.table.exportExcel()" shiro:hasPermission="wip:confirm:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('wip:confirm:edit')}]];
        var removeFlag = [[${@permission.hasPermi('wip:confirm:remove')}]];
        var prefix = ctx + "wip/confirm";
        var columnArrys = [
            {
                checkbox: true
            },
            {
                field: 'id',
                title: 'uuid',
                visible: false
            },
            {
                field: 'customerCode',
                title: '客户编码',
                visible: false,
                sortable: true
            },
            {
                field: 'customerName',
                title: '客户名称'
            },
            {
                field: 'partName',
                title: '产品名称',
                sortable: true
            },
            {
                field: 'lotType',
                title: '批次类型',
                sortable: true
            },
            {
                field: 'mainQty',
                title: '数量'
            }
        ];
        var splictPage = [10, 20, 30, 50];

        $(function() {
            layui.use('laydate', function(){
                var laydate = layui.laydate;
                laydate.render({
                    elem: '#timeFlag',
                    type: 'date'
                });
            });

            var options = {
                url: prefix + "/list",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "客户wip已确认数据",
                columns: columnArrys,
                pageList: splictPage,
                sortName: "customerCode"
            };
            $.table.init(options);
        });

        function cancelconfirm() {
            var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            $.modal.confirm("确认要取消确认选中的" + rows.length + "条数据吗?", function() {
                $.ajax({
                    url: prefix + "/cancelconfirm",
                    data: { "ids": rows.join() },
                    type: "post",
                    async : false,
                    beforeSend : function () {
                        $.modal.loading("正在处理中......");
                    },
                    error : function(request) {
                        $.modal.alertError("系统错误！");
                    },
                    success : function(data) {
                        $.modal.alertSuccess("取消确认成功！");
                        $.table.refresh();
                    },
                    complete: function () {
                        $.modal.closeLoading();
                    }
                });
            });
        }
    </script>
</body>
</html>